/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./libs/bootstrap')

import Cookies from 'js-cookie'
import store from './store'
import router from './router'
import i18n from './lang' // Internationalization
import './libs/permission' // permission control
import './libs/errorLog' // error log
import './mock' // simulation data


window.Vue = require('vue')

import Element from 'element-ui'

import * as filters from './filters' // global filters

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})
// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
/**
 * 自定义组件
 */
window.ModelDataSource = require('./libs/ModelDataSource')
Vue.use(ModelDataSource)
window.ListDataSource = require('./libs/ListDataSource')
Vue.use(ListDataSource)

/**
 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 *
 * Eg. ./components/ExampleComponent.vue ->
 * <example-component></example-component>
 */

// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0],
// files(key).default))
import App from './App.vue'

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

const app = new Vue({
  el: '#app',
  router: router,
  store: store,
  render: h => h(App)
})
